package com.web.oa.controller;

import com.github.pagehelper.PageInfo;
import com.web.oa.pojo.ActiveEmployee;
import com.web.oa.pojo.Baoxiaobill;
import com.web.oa.service.BaoXiaoService;
import com.web.oa.service.WorkFlowService;
import org.apache.ibatis.annotations.Param;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author Lenovo
 *
 */
@Controller
public class BaoXiaoBillController {
    @Autowired
    private BaoXiaoService baoXiaoService;
    @Autowired
    private WorkFlowService workFlowService;

    /**
     * 跳转主页面
     * @param model 模型
     * @return java.lang.String
     * @author Lenovo
     * @date 2021/11/3 9:13
     */
    @RequestMapping("/main")
    public String main(Model model){
        ActiveEmployee activeEmployee = (ActiveEmployee) SecurityUtils.getSubject().getPrincipal();
        model.addAttribute("activeEmployee",activeEmployee);
        return "index";
    }

    /**
     *  跳转报销申请
     * @return java.lang.String
     * @author Lenovo
     * @date 2021/11/3 9:12
     */
    @RequestMapping("/apply_baoxiao")
    public String apply_baoxiao(){
        return "apply_baoxiao";
    }

    /**
     *  跳转我的报销单
     * @param model 模型
     * @param pageNum 当前页
     * @return java.lang.String
     * @author Lenovo
     * @date 2021/11/3 9:14
     */
    @RequestMapping("/myBaoxiaoBill")
    public String myBaoxiaoBill(Model model, @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum){
        ActiveEmployee activeEmployee = (ActiveEmployee) SecurityUtils.getSubject().getPrincipal();
        PageInfo<Baoxiaobill> pageInfo = baoXiaoService.findLeaveBillById(activeEmployee.getEmployeeId(), pageNum);
        model.addAttribute("pageInfo",pageInfo);
        return "baoxiaobill";
    }
}
